package genealogy.deprecated.datamodel.pedigree;

import genealogy.deprecated.datamodel.pedigree.visitors.IPedigreeVisitor;

import java.io.Serializable;

/**
 * @author Steve
 */
@Deprecated
public class LifeEvent implements Serializable, IPedigreeVisitable {

	// serialVersionUID
	private static final long serialVersionUID = -6612235380576349334L;

	private Date m_date;

	private Location m_location;

	private EventType m_eventType;

	private String m_eventName;

	/**
	 * Constructor
	 */
	public LifeEvent() {
		m_eventType = EventType.DEFAULT;
	}

	/**
	 * Constructor
	 * 
	 * @param date
	 * @param location
	 */
	public LifeEvent(Date date, Location location) {
		super();
		m_eventType = EventType.DEFAULT;
		m_date = date;
		m_location = location;
	}

	/**
	 * @return the date
	 */
	public Date getDate() {
		return m_date;
	}

	/**
	 * @param date the date to set
	 */
	public void setDate(Date date) {
		m_date = date;
	}

	/**
	 * @return the location
	 */
	public Location getLocation() {
		return m_location;
	}

	/**
	 * @param location the location to set
	 */
	public void setLocation(Location location) {
		m_location = location;
	}

	/**
	 * @return the eventType
	 */
	public EventType getEventType() {
		return m_eventType;
	}

	/**
	 * @param eventType the eventType to set
	 */
	public void setEventType(EventType eventType) {
		m_eventType = eventType;
	}

	/**
	 * @param eventName the eventName to set
	 */
	protected void setEventName(String eventName) {
		m_eventName = eventName;
	}

	/**
	 * @return the eventName
	 */
	public String getEventName() {
		return m_eventName;
	}

	public String toString() {
		return m_eventName + (m_date == null ? "" : "date: " + m_date + "\n")
				+ (m_location == null ? "" : "Location: " + m_location + "\n");
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see java.lang.Object#equals(java.lang.Object)
	 */
	@Override
	public boolean equals(Object arg0) {
		if(arg0 == null){
			return false;
		}
		
		if (arg0 instanceof LifeEvent)
		{
			LifeEvent e = (LifeEvent) arg0;
			return m_date.equals(e.m_date) && m_location.equals(e.m_location)
					&& m_eventName.equalsIgnoreCase(e.m_eventName);
		}
		return false;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see genealogy.datamodel.pedigree.IPedigreeVisitable#accept(genealogy.datamodel.pedigree.visitors.AbstractPedigreeVisitor)
	 */
	public void accept(IPedigreeVisitor visitor) {
		visitor.visit(this);
		if (m_date != null)
		{
			m_date.accept(visitor);
		}
		if (m_location != null)
		{
			m_location.accept(visitor);
		}
		visitor.endVisit();
	}
}
